package com.difsonapps.android.marker.beans;

import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

public class FeedItem {
	public static final String TYPE_PHOTO_ACTIVITY = "photo_activity";
	public static final String TYPE_VIDEO_ACTIVITY = "video_activity";
	public static final String TYPE_MARK_ACTIVITY = "mark_activity";
	public static final String TYPE_LIKE_ACTIVITY = "like_activity";
	public static final String TYPE_COMMENT_ACTIVITY = "comment_activity";
    //private int id;
    private String name, status, image, profilePic, timeStamp, url;
    
    private int id;
    private String type;
    private String createdAt;
    private String date;
    private User user;
    private Photo photo;
    private Video video;
    

    private String now;
    private String relativeDate;
    
 
    public FeedItem() {
    }
 
    public FeedItem(int id, String name, String image, String status,
            String profilePic, String timeStamp, String url) {
        super();
        this.id = id;
        this.name = name;
        this.image = image;
        this.status = status;
        this.profilePic = profilePic;
        this.timeStamp = timeStamp;
        this.url = url;
    }
 
    public int getId() {
        return id;
    }
 
    public void setId(int id) {
        this.id = id;
    }
    
    
 
    public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getCreatedAt() {
		return createdAt;
	}

	public void setCreatedAt(String createdAt) {
		this.createdAt = createdAt;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Photo getPhoto() {
		return photo;
	}

	public void setPhoto(Photo photo) {
		this.photo = photo;
	}
	
	
	
	public Video getVideo() {
		return video;
	}

	public void setVideo(Video video) {
		this.video = video;
	}

	public static FeedItem parseFromJsonObject(JSONObject json){
		if(json==null || !json.has("id")) return null;
		FeedItem result = new FeedItem();
		try {
			result.setId(json.getInt("id"));
			result.setType(json.getString("type"));
			result.setCreatedAt(json.getString("created_at"));
			result.setDate(json.getString("date"));
			result.setUser(User.parseFromJsonObject(json.getJSONObject("user")));
			result.setPhoto(json.has("photo")?Photo.parseFromJsonObject(json.getJSONObject("photo")):null);
			result.setVideo(json.has("video")?Video.parseFromJsonObject(json.getJSONObject("video")):null);
		} catch (JSONException e) {
			e.printStackTrace();
			Log.e("Parse User From JSON", e.getMessage());
			return null;
		}
		return result;
	}
	

	public String getName() {
        return name;
    }
 
    public void setName(String name) {
        this.name = name;
    }
 
    public String getImge() {
        return image;
    }
 
    public void setImge(String image) {
        this.image = image;
    }
 
    public String getStatus() {
        return status;
    }
 
    public void setStatus(String status) {
        this.status = status;
    }
 
    public String getProfilePic() {
        return profilePic;
    }
 
    public void setProfilePic(String profilePic) {
        this.profilePic = profilePic;
    }
 
    public String getTimeStamp() {
        return timeStamp;
    }
 
    public void setTimeStamp(String timeStamp) {
        this.timeStamp = timeStamp;
    }
    
    
 
    public String getNow() {
		return now;
	}

	public void setNow(String now) {
		this.now = now;
	}

	public String getRelativeDate() {
		return relativeDate;
	}

	public void setRelativeDate(String relativeDate) {
		this.relativeDate = relativeDate;
	}

	public String getUrl() {
        return url;
    }
 
    public void setUrl(String url) {
        this.url = url;
    }
    
    
    
}

